from django import template

register = template.Library()


@register.filter
def page_range(value):
    """
    生成一个从1到value的范围列表，用于分页
    """
    try:
        value = int(value)
    except (ValueError, TypeError):
        return range(0)
    return range(1, value + 1)
